





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.relay.analysis &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
        <script src="../../../../_static/jquery.js"></script>
        <script src="../../../../_static/underscore.js"></script>
        <script src="../../../../_static/doctools.js"></script>
        <script src="../../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../../search.html" />
    <link rel="next" title="tvm.relay.backend" href="backend.html" />
    <link rel="prev" title="tvm.relay.transform" href="transform.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../../index.html">
          

          
            
            <img src="../../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="../error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../target.html">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="../driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="../auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="../micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="../contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="../graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="../index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.relay.analysis</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../../_sources/reference/api/python/relay/analysis.rst.txt" rel="nofollow"> <img src="../../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.relay.analysis">
<span id="tvm-relay-analysis"></span><h1>tvm.relay.analysis<a class="headerlink" href="#module-tvm.relay.analysis" title="永久链接至标题">¶</a></h1>
<p>包含分析的Relay IR命名空间的passes。</p>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.AnnotatedRegionSet" title="tvm.relay.analysis.AnnotatedRegionSet"><code class="xref py py-obj docutils literal notranslate"><span class="pre">AnnotatedRegionSet</span></code></a>(expr, region_begin_op, …)</p></td>
<td><p>表示relay expression的类拆分为区域。</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.CallGraph" title="tvm.relay.analysis.CallGraph"><code class="xref py py-obj docutils literal notranslate"><span class="pre">CallGraph</span></code></a>(module)</p></td>
<td><p>表示call graph的类。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.Feature" title="tvm.relay.analysis.Feature"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Feature</span></code></a>(value)</p></td>
<td><p>程序可能包含的功能。</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.count_layers" title="tvm.relay.analysis.count_layers"><code class="xref py py-obj docutils literal notranslate"><span class="pre">count_layers</span></code></a>(expr, valid_ops)</p></td>
<td><p>Determine the number of layers of specified ops in a graph.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.all_dtypes" title="tvm.relay.analysis.all_dtypes"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all_dtypes</span></code></a>(expr)</p></td>
<td><p>Collect set of all data types used in <cite>expr</cite>.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.all_type_vars" title="tvm.relay.analysis.all_type_vars"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all_type_vars</span></code></a>(expr[, mod])</p></td>
<td><p>Get all type variables from expression/type e</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.all_vars" title="tvm.relay.analysis.all_vars"><code class="xref py py-obj docutils literal notranslate"><span class="pre">all_vars</span></code></a>(expr)</p></td>
<td><p>Get all vars from expression expr in post-DFS order.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.bound_type_vars" title="tvm.relay.analysis.bound_type_vars"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bound_type_vars</span></code></a>(expr[, mod])</p></td>
<td><p>Get bound type variables from expression/type e</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.bound_vars" title="tvm.relay.analysis.bound_vars"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bound_vars</span></code></a>(expr)</p></td>
<td><p>Get bound vars from expression expr in post-DFS order.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.check_basic_block_normal_form" title="tvm.relay.analysis.check_basic_block_normal_form"><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_basic_block_normal_form</span></code></a>(expr)</p></td>
<td><p>Check whether an expression is in the basic block form</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.check_constant" title="tvm.relay.analysis.check_constant"><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_constant</span></code></a>(expr)</p></td>
<td><p>Check whether an expression is constant</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.check_kind" title="tvm.relay.analysis.check_kind"><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_kind</span></code></a>(t[, mod])</p></td>
<td><p>Check that the type is well kinded and return the kind.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.cpu" title="tvm.relay.analysis.cpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cpu</span></code></a>([dev_id])</p></td>
<td><p>Construct a CPU device</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.detect_feature" title="tvm.relay.analysis.detect_feature"><code class="xref py py-obj docutils literal notranslate"><span class="pre">detect_feature</span></code></a>(a[, b])</p></td>
<td><p>Detect the feature used in a relay program.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.extract_fused_functions" title="tvm.relay.analysis.extract_fused_functions"><code class="xref py py-obj docutils literal notranslate"><span class="pre">extract_fused_functions</span></code></a>(mod)</p></td>
<td><p>Pass to extract IRModule of only fused primitive functions.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.free_type_vars" title="tvm.relay.analysis.free_type_vars"><code class="xref py py-obj docutils literal notranslate"><span class="pre">free_type_vars</span></code></a>(expr[, mod])</p></td>
<td><p>Get free type variables from expression/type e</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.free_vars" title="tvm.relay.analysis.free_vars"><code class="xref py py-obj docutils literal notranslate"><span class="pre">free_vars</span></code></a>(expr)</p></td>
<td><p>Get free Vars from expression expr in Post DFS order.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.get_calibration_data" title="tvm.relay.analysis.get_calibration_data"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_calibration_data</span></code></a>(mod, data)</p></td>
<td><p>Get the calibration data of a given relay graph</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.get_total_mac_number" title="tvm.relay.analysis.get_total_mac_number"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_total_mac_number</span></code></a>(expr)</p></td>
<td><p>Count the number of MACs (multiply-accumulate) of a model</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.list_op_freqs" title="tvm.relay.analysis.list_op_freqs"><code class="xref py py-obj docutils literal notranslate"><span class="pre">list_op_freqs</span></code></a>(mod)</p></td>
<td><p>Pass to extract unique operator names and how frequently they appear in an IRModule.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.post_order_visit" title="tvm.relay.analysis.post_order_visit"><code class="xref py py-obj docutils literal notranslate"><span class="pre">post_order_visit</span></code></a>(expr, fvisit)</p></td>
<td><p>Recursively visit the ir in post DFS order node, apply fvisit.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.search_fc_transpose" title="tvm.relay.analysis.search_fc_transpose"><code class="xref py py-obj docutils literal notranslate"><span class="pre">search_fc_transpose</span></code></a>(expr)</p></td>
<td><p>Search fc weight name in the patten: y = nn.dense(x, transpose(w, [1, 0]))</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.unmatched_cases" title="tvm.relay.analysis.unmatched_cases"><code class="xref py py-obj docutils literal notranslate"><span class="pre">unmatched_cases</span></code></a>(match[, mod])</p></td>
<td><p>Finds cases that the match expression does not catch, if any.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.well_formed" title="tvm.relay.analysis.well_formed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">well_formed</span></code></a>(expr)</p></td>
<td><p>Check that each Var is only bound once (well formed).</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.analysis.AnnotatedRegionSet">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">AnnotatedRegionSet</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">region_begin_op</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">region_end_op</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.AnnotatedRegionSet" title="永久链接至目标">¶</a></dt>
<dd><p>表示relay expression的类拆分为区域。</p>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.AnnotatedRegionSet.get_region" title="tvm.relay.analysis.AnnotatedRegionSet.get_region"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_region</span></code></a>(expr)</p></td>
<td><p>Get the region an expression belongs to.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.analysis.AnnotatedRegionSet.get_region">
<span class="sig-name descname"><span class="pre">get_region</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.AnnotatedRegionSet.get_region" title="永久链接至目标">¶</a></dt>
<dd><p>Get the region an expression belongs to.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The expression.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p>The region containing the expression.
None if not found.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>region</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.analysis.CallGraph">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">CallGraph</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">module</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.CallGraph" title="永久链接至目标">¶</a></dt>
<dd><p>表示call graph的类。</p>
<p><strong>Attributes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.CallGraph.module" title="tvm.relay.analysis.CallGraph.module"><code class="xref py py-obj docutils literal notranslate"><span class="pre">module</span></code></a></p></td>
<td><p>Return the contained Relay IR module.</p></td>
</tr>
</tbody>
</table>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.CallGraph.ref_count" title="tvm.relay.analysis.CallGraph.ref_count"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ref_count</span></code></a>(var)</p></td>
<td><p>Return the number of references to the global var</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.CallGraph.global_call_count" title="tvm.relay.analysis.CallGraph.global_call_count"><code class="xref py py-obj docutils literal notranslate"><span class="pre">global_call_count</span></code></a>(var)</p></td>
<td><p>Return the number of global function calls from a given global var.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.CallGraph.is_recursive" title="tvm.relay.analysis.CallGraph.is_recursive"><code class="xref py py-obj docutils literal notranslate"><span class="pre">is_recursive</span></code></a>(var)</p></td>
<td><p>Return if the function corresponding to a var is a recursive function.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.CallGraph.print_var" title="tvm.relay.analysis.CallGraph.print_var"><code class="xref py py-obj docutils literal notranslate"><span class="pre">print_var</span></code></a>(var)</p></td>
<td><p>Print a call graph of a global function by name or by variable.</p></td>
</tr>
</tbody>
</table>
<dl class="py property">
<dt class="sig sig-object py" id="tvm.relay.analysis.CallGraph.module">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">module</span></span><a class="headerlink" href="#tvm.relay.analysis.CallGraph.module" title="永久链接至目标">¶</a></dt>
<dd><p>Return the contained Relay IR module.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>None</strong> – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – The contained IRModule</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="../ir.html#tvm.ir.IRModule" title="tvm.ir.IRModule">tvm.ir.IRModule</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.analysis.CallGraph.ref_count">
<span class="sig-name descname"><span class="pre">ref_count</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">var</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.CallGraph.ref_count" title="永久链接至目标">¶</a></dt>
<dd><p>Return the number of references to the global var</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>var</strong> (<em>Union</em><em>[</em><a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String"><em>String</em></a><em>, </em><em>tvm.relay.GlobalVar</em><em>]</em>) – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – The number reference to the global var</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.analysis.CallGraph.global_call_count">
<span class="sig-name descname"><span class="pre">global_call_count</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">var</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.CallGraph.global_call_count" title="永久链接至目标">¶</a></dt>
<dd><p>Return the number of global function calls from a given global var.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>var</strong> (<em>Union</em><em>[</em><a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String"><em>String</em></a><em>, </em><em>tvm.relay.GlobalVar</em><em>]</em>) – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – The number of global function calls from the given var.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.analysis.CallGraph.is_recursive">
<span class="sig-name descname"><span class="pre">is_recursive</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">var</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.CallGraph.is_recursive" title="永久链接至目标">¶</a></dt>
<dd><p>Return if the function corresponding to a var is a recursive
function.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>var</strong> (<em>Union</em><em>[</em><a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String"><em>String</em></a><em>, </em><em>tvm.relay.GlobalVar</em><em>]</em>) – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – If the function corresponding to var is recurisve.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Boolean</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.relay.analysis.CallGraph.print_var">
<span class="sig-name descname"><span class="pre">print_var</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">var</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.CallGraph.print_var" title="永久链接至目标">¶</a></dt>
<dd><p>Print a call graph of a global function by name or by variable.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>var</strong> (<em>Union</em><em>[</em><a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String"><em>String</em></a><em>, </em><em>tvm.relay.GlobalVar</em><em>]</em>) – The name or global variable.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – The call graph represented in string.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String">String</a></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.count_layers">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">count_layers</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">valid_ops</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.count_layers" title="永久链接至目标">¶</a></dt>
<dd><p>Determine the number of layers of specified ops in a graph.
This pass computes only the deepest chain of ops rather than the
total number of ops in a graph. Thus, if there are two parallel
convolutions (for example), they would be considered a single layer.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<em>tvm.relay.Expr</em><em>, </em><em>tvm.relay.Function</em><em>, or </em><em>tvm.ir.IRModule.</em>) – The input expression.</p></li>
<li><p><strong>valid_ops</strong> (<a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List"><em>List</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>]</em>) – A list of the operations that should be included in the count.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>layer_count</strong> – The number of layers of the specified operations found in the graph.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.relay.analysis.Feature">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">Feature</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.Feature" title="永久链接至目标">¶</a></dt>
<dd><p>程序可能包含的功能。</p>
<p><strong>Attributes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.analysis.Feature.fMatch" title="tvm.relay.analysis.Feature.fMatch"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fMatch</span></code></a></p></td>
<td><p>Whether any non-atom fragment of the program is shared, making the program a graph.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.analysis.Feature.fGraph" title="tvm.relay.analysis.Feature.fGraph"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fGraph</span></code></a></p></td>
<td><p>Whether there is local fixpoint in the program.</p></td>
</tr>
</tbody>
</table>
<dl class="py attribute">
<dt class="sig sig-object py" id="tvm.relay.analysis.Feature.fMatch">
<span class="sig-name descname"><span class="pre">fMatch</span></span><em class="property"> <span class="pre">=</span> <span class="pre">14</span></em><a class="headerlink" href="#tvm.relay.analysis.Feature.fMatch" title="永久链接至目标">¶</a></dt>
<dd><p>Whether any non-atom fragment of the program is shared, making the program a graph.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tvm.relay.analysis.Feature.fGraph">
<span class="sig-name descname"><span class="pre">fGraph</span></span><em class="property"> <span class="pre">=</span> <span class="pre">15</span></em><a class="headerlink" href="#tvm.relay.analysis.Feature.fGraph" title="永久链接至目标">¶</a></dt>
<dd><p>Whether there is local fixpoint in the program.</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.all_dtypes">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">all_dtypes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.all_dtypes" title="永久链接至目标">¶</a></dt>
<dd><p>Collect set of all data types used in <cite>expr</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – Set of data types used in the expression (e.g., <cite>{‘int8’, ‘int32’}</cite>)</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Set[<a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String">String</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.all_type_vars">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">all_type_vars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.all_type_vars" title="永久链接至目标">¶</a></dt>
<dd><p>Get all type variables from expression/type e</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<em>Union</em><em>[</em><em>tvm.relay.Expr</em><em>,</em><em>tvm.relay.Type</em><em>]</em>) – The input expression/type</p></li>
<li><p><strong>mod</strong> (<em>Optional</em><em>[</em><em>tvm.IRModule</em><em>]</em>) – The global module</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>free</strong> – The list of all type variables in post-DFS order</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[tvm.relay.TypeVar]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.all_vars">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">all_vars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.all_vars" title="永久链接至目标">¶</a></dt>
<dd><p>Get all vars from expression expr in post-DFS order.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>free</strong> – The list of all variables in post-DFS order.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[tvm.relay.Var]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.bound_type_vars">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">bound_type_vars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.bound_type_vars" title="永久链接至目标">¶</a></dt>
<dd><p>Get bound type variables from expression/type e</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<em>Union</em><em>[</em><em>tvm.relay.Expr</em><em>,</em><em>tvm.relay.Type</em><em>]</em>) – The input expression/type</p></li>
<li><p><strong>mod</strong> (<em>Optional</em><em>[</em><em>tvm.IRModule</em><em>]</em>) – The global module</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>free</strong> – The list of bound type variables in post-DFS order</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[tvm.relay.TypeVar]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.bound_vars">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">bound_vars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.bound_vars" title="永久链接至目标">¶</a></dt>
<dd><p>Get bound vars from expression expr in post-DFS order.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>free</strong> – The list of bound variables in post-DFS order.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[tvm.relay.Var]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.check_basic_block_normal_form">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">check_basic_block_normal_form</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.check_basic_block_normal_form" title="永久链接至目标">¶</a></dt>
<dd><p>Check whether an expression is in the basic block form</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – Whether the expression is in the basic block form.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.check_constant">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">check_constant</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.check_constant" title="永久链接至目标">¶</a></dt>
<dd><p>Check whether an expression is constant</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – Whether the expression is constant.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.check_kind">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">check_kind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">t</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.check_kind" title="永久链接至目标">¶</a></dt>
<dd><p>Check that the type is well kinded and return the kind.
For example, this mean type cannot has tensor of tensor, or is a tuple type
of 2 shapes.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>t</strong> (<em>tvm.relay.Type</em>) – The type to check</p></li>
<li><p><strong>mod</strong> (<em>Optional</em><em>[</em><em>tvm.IRModule</em><em>]</em>) – The global module.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>kind</strong> – the kind of t</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Kind</p>
</dd>
</dl>
<p class="rubric">实际案例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">assert</span> <span class="n">check_kind</span><span class="p">(</span><span class="n">relay</span><span class="o">.</span><span class="n">TupleType</span><span class="p">([</span><span class="n">relay</span><span class="o">.</span><span class="n">TypeParam</span><span class="p">(</span><span class="s1">&#39;tp1&#39;</span><span class="p">,</span> <span class="n">relay</span><span class="o">.</span><span class="n">Kind</span><span class="o">.</span><span class="n">Shape</span><span class="p">)]))</span> <span class="o">==</span> <span class="n">Shape</span>
<span class="k">assert</span> <span class="n">check_kind</span><span class="p">(</span><span class="n">relay</span><span class="o">.</span><span class="n">TupleType</span><span class="p">([</span><span class="n">relay</span><span class="o">.</span><span class="n">TypeParam</span><span class="p">(</span><span class="s1">&#39;tp1&#39;</span><span class="p">,</span> <span class="n">relay</span><span class="o">.</span><span class="n">Kind</span><span class="o">.</span><span class="n">Type</span><span class="p">)]))</span> <span class="o">==</span> <span class="n">Type</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.cpu">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">cpu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dev_id</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.cpu" title="永久链接至目标">¶</a></dt>
<dd><p>Construct a CPU device</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>dev_id</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em>, </em><em>optional</em>) – The integer device id</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>dev</strong> – The created device</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="../runtime.html#tvm.runtime.Device" title="tvm.runtime.Device">Device</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.detect_feature">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">detect_feature</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">a</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">b</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.detect_feature" title="永久链接至目标">¶</a></dt>
<dd><p>Detect the feature used in a relay program.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<em>Union</em><em>[</em><em>tvm.relay.Expr</em><em>, </em><em>tvm.IRModule</em><em>]</em>) – The input expression or module.</p></li>
<li><p><strong>b</strong> (<em>Optional</em><em>[</em><em>Union</em><em>[</em><em>tvm.relay.Expr</em><em>, </em><em>tvm.IRModule</em><em>]</em><em>]</em>) – The input expression or module.
The two arguments cannot both be expression or module.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>features</strong> – Features used in the program.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>Set[<a class="reference internal" href="#tvm.relay.analysis.Feature" title="tvm.relay.analysis.Feature">Feature</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.extract_fused_functions">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">extract_fused_functions</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.extract_fused_functions" title="永久链接至目标">¶</a></dt>
<dd><p>Pass to extract IRModule of only fused primitive functions.</p>
<p>The ExtractFusedFunctions pass invokes SimplifyInference, FuseOps(3),
and ExtractFusedFunctions in that order</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>mod</strong> (<em>tvm.IRModule</em>) – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – A module containing only fused primitive functions</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a>, tvm.relay.function.Function]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.free_type_vars">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">free_type_vars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.free_type_vars" title="永久链接至目标">¶</a></dt>
<dd><p>Get free type variables from expression/type e</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<em>Union</em><em>[</em><em>tvm.relay.Expr</em><em>,</em><em>tvm.relay.Type</em><em>]</em>) – The input expression/type</p></li>
<li><p><strong>mod</strong> (<em>Optional</em><em>[</em><em>tvm.IRModule</em><em>]</em>) – The global module</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>free</strong> – The list of free type variables in post-DFS order</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[tvm.relay.TypeVar]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.free_vars">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">free_vars</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.free_vars" title="永久链接至目标">¶</a></dt>
<dd><p>Get free Vars from expression expr in Post DFS order.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>free</strong> – The list of free variables in post DFS order.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.List" title="tvm.relay.dataflow_pattern.List">List</a>[tvm.relay.Var]</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>The fact that Vars are post-DFS ordred are useful in
neural networks: usually this means weights of previous
are ordered first.</p>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.get_calibration_data">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">get_calibration_data</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.get_calibration_data" title="永久链接至目标">¶</a></dt>
<dd><p>Get the calibration data of a given relay graph</p>
<p>This pass uses the graph executor to get the calibration data of a module, which
includes the input and output values of each function. The returned data uses
the GlobalVar of each function as a key. Users can further access the inputs and
outputs by using <cite>inputs</cite> or  <cite>outputs</cite> as the key.</p>
<p>Following are some limitations:
1. The input module (graph) cannot have control flows.
2. The input arguments of each function cannot be tuples (outputs can be tuples).
3. We only handle top-level functions (i.e., nested function is not handled).
4. We only handle functions with <cite>Compiler</cite> attribute being set.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mod</strong> (<em>tvm.IRModule</em>) – The input module for collecting the calibration data</p></li>
<li><p><strong>data</strong> (<a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="../ndarray.html#tvm.nd.NDArray" title="tvm.nd.NDArray"><em>NDArray</em></a><em>]</em>) – The input data for running the module</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>data</strong></p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[tvm.relay.GlobalVar, <a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a>, <a class="reference internal" href="../ndarray.html#tvm.nd.NDArray" title="tvm.nd.NDArray">NDArray</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.get_total_mac_number">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">get_total_mac_number</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.get_total_mac_number" title="永久链接至目标">¶</a></dt>
<dd><p>Count the number of MACs (multiply-accumulate) of a model</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The number of MACs (multiply-accumulate) of a model</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>int64</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.list_op_freqs">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">list_op_freqs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mod</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.list_op_freqs" title="永久链接至目标">¶</a></dt>
<dd><p>Pass to extract unique operator names and how frequently they appear
in an IRModule. Fused functions are traversed to count the operators
that compose them.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>mod</strong> (<em>tvm.IRModule</em>) – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – Dict of unique operator names to frequency</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a>, <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)">int</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.post_order_visit">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">post_order_visit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fvisit</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.post_order_visit" title="永久链接至目标">¶</a></dt>
<dd><p>Recursively visit the ir in post DFS order node,
apply fvisit. Each node is guaranteed to be visited
only once.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression.</p></li>
<li><p><strong>fvisit</strong> (<em>function</em>) – The visitor function to be applied.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.search_fc_transpose">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">search_fc_transpose</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.search_fc_transpose" title="永久链接至目标">¶</a></dt>
<dd><p>Search fc weight name in the patten: y = nn.dense(x, transpose(w, [1, 0]))</p>
<p>This function is used in the data_dep_optimization.simplify_fc_transpose method</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – </p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>ret</strong> – Array of weight variable name in pattern y = nn.dense(x, transpose(w, [1, 0]))</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="../ir.html#tvm.ir.Array" title="tvm.ir.Array">Array</a>[<a class="reference internal" href="../runtime.html#tvm.runtime.String" title="tvm.runtime.String">String</a>]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.unmatched_cases">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">unmatched_cases</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">match</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mod</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.unmatched_cases" title="永久链接至目标">¶</a></dt>
<dd><p>Finds cases that the match expression does not catch, if any.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>match</strong> (<em>tvm.relay.Match</em>) – The match expression</p></li>
<li><p><strong>mod</strong> (<em>Optional</em><em>[</em><em>tvm.IRModule</em><em>]</em>) – The module (defaults to an empty module)</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>missing_patterns</strong> – Patterns that the match expression does not catch.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>[tvm.relay.Pattern]</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.analysis.well_formed">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.analysis.</span></span><span class="sig-name descname"><span class="pre">well_formed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">expr</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.analysis.well_formed" title="永久链接至目标">¶</a></dt>
<dd><p>Check that each Var is only bound once (well formed).</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>expr</strong> (<em>tvm.relay.Expr</em>) – The input expression</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>well_form</strong> – Whether the input expression is well formed</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)">bool</a></p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="backend.html" class="btn btn-neutral float-right" title="tvm.relay.backend" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="transform.html" class="btn btn-neutral float-left" title="tvm.relay.transform" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>